#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e5 + 10;
int n, m;
int a[N], b[N];
bool check(int x)
{
	int l = 0, r = n + 1;
	while (l + 1 != r) {
		int mid = l + r >> 1;
		if (a[mid] < x)l = mid;
		else r = mid;
	}
	if (a[r] == x)return 1;
	return 0;
}
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++)cin >> a[i];
	for (int i = 1; i <= m; i++)cin >> b[i];
	sort(a + 1, a + n + 1);
	//sort(b + 1, b + m + 1);
	for (int i = 1; i <= m; i++) {
		if (check(b[i])) {
			cout << b[i] << " ";
		}
	}
	return 0;
}